--
-- Author: ping.wang
-- Date: 2018-09-28 18:19:11
--
-- newCrystalInsertTipsView
--


local ClassRef = class("newCrystalInsertTipsView",function()
    return ccui.Layout:create()
end)

local panelOriginHeight = 0

function ClassRef:ctor()
    local function createModuleNode(uiPath, uiNodeName, parent)
        local node = cc.uiloader:load( uiPath )
        local moduleNode = node:getChildByName( uiNodeName )
        moduleNode:retain()
        moduleNode:removeFromParent()
        parent:addChild( moduleNode )
        moduleNode:release()
        return moduleNode
    end
    self.mUINode = createModuleNode( Res.Tips_CrystalInsert, "Panel", self )
    self:setContentSize( self.mUINode:getContentSize() )
    ccui.Helper:doLayout( self.mUINode )

    self._text1 = self.mUINode:getChildByName( "text_1" )
    self._text2 = self.mUINode:getChildByName( "text_2" )
    self._oldText1PosY = self._text1:getPositionY()
    panelOriginHeight = self.mUINode:getContentSize().height
end

function ClassRef:refreshContent(haveEnoughTypeRock,str1,str2)
    local panelContetsizeWidth = self.mUINode:getContentSize2()
    self._text2:setVisible(haveEnoughTypeRock)

    local tempH = 16
    if haveEnoughTypeRock then
        tempH = 0
    end
    if str1 then
        self._text1:setString(str1)
    end
    if str2 then
        self._text2:setString(str2)
    end

    self._text1:setPositionY(self._oldText1PosY - tempH)
    self.mUINode:setContentSize( cc.size( panelContetsizeWidth, panelOriginHeight - tempH  ) )
    self:setContentSize( cc.size( panelContetsizeWidth, panelOriginHeight - tempH ) )
    ccui.Helper:doLayout( self.mUINode )
end

return ClassRef
